Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(internal): remove time functions from compat module #10861

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vitor-de-araujo
Copy link
Contributor

@vitor-de-araujo vitor-de-araujo commented Sep 30, 2024

This PR removes 4 time-related functions from ddtrace.internal.compat that existed for compatibility with Python < 3.7, and replaces all uses with the corresponding functions from the builtin time module: time_ns, monotonic, monotonic_ns, process_time_ns.

The original motivation for this was noticing that the fallback code for time_ns had the wrong multiplier [edit: it's not actually wrong, just written in a weird way], and then checking that we don't really need these functions anymore, as we only support Python >= 3.7.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Sep 30, 2024

CODEOWNERS have been resolved as:

benchmarks/rate_limiter/scenario.py                                     @DataDog/apm-core-python
ddtrace/_trace/span.py                                                  @DataDog/apm-sdk-api-python
ddtrace/contrib/internal/botocore/services/kinesis.py                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/kafka/patch.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/debugging/_debugger.py                                          @DataDog/debugger-python
ddtrace/internal/compat.py                                              @DataDog/python-guild @DataDog/apm-core-python
ddtrace/internal/opentelemetry/span.py                                  @DataDog/apm-sdk-api-python
ddtrace/internal/rate_limiter.py                                        @DataDog/apm-core-python
ddtrace/internal/utils/time.py                                          @DataDog/apm-core-python
ddtrace/profiling/collector/_lock.py                                    @DataDog/profiling-python
ddtrace/profiling/collector/memalloc.py                                 @DataDog/profiling-python
ddtrace/profiling/collector/stack.pyx                                   @DataDog/profiling-python
ddtrace/profiling/event.py                                              @DataDog/profiling-python
ddtrace/profiling/scheduler.py                                          @DataDog/profiling-python
tests/debugging/mocking.py                                              @DataDog/debugger-python
tests/integration/test_sampling.py                                      @DataDog/apm-core-python
tests/profiling/exporter/test_http.py                                   @DataDog/profiling-python
tests/profiling/test_accuracy.py                                        @DataDog/profiling-python
tests/profiling/test_scheduler.py                                       @DataDog/profiling-python
tests/submod/stuff.py                                                   @DataDog/apm-core-python
tests/tracer/test_rate_limiter.py                                       @DataDog/apm-sdk-api-python

@vitor-de-araujo vitor-de-araujo changed the title Remove time functions from compat module chore(internal): remove time functions from compat module Sep 30, 2024
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Sep 30, 2024

Datadog Report

Branch report: vitor-de-araujo/remove-compat-time-ns
Commit report: 6ee1543
Test service: dd-trace-py

✅ 0 Failed, 592 Passed, 694 Skipped, 18m 33.31s Total duration (18m 43.51s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Sep 30, 2024

Benchmarks

Benchmark execution time: 2024-09-30 16:08:15

Comparing candidate commit f2548ac in PR branch vitor-de-araujo/remove-compat-time-ns with baseline commit 1c13106 in branch main.

Found 8 performance improvements and 0 performance regressions! Performance is the same for 363 metrics, 53 unstable metrics.

scenario:iast_aspects-aspect_iast_do_lower

  • 🟩 max_rss_usage [-2.797MB; -2.534MB] or [-9.528%; -8.633%]

scenario:iast_aspects-aspect_iast_do_lstrip

  • 🟩 max_rss_usage [-2.793MB; -2.409MB] or [-9.570%; -8.257%]

scenario:iast_aspects-aspect_iast_do_modulo

  • 🟩 max_rss_usage [-2.718MB; -2.393MB] or [-9.302%; -8.190%]

scenario:iast_aspects-aspect_iast_do_repr

  • 🟩 max_rss_usage [-2.754MB; -2.527MB] or [-9.380%; -8.608%]

scenario:iast_aspects-aspect_iast_do_slice

  • 🟩 max_rss_usage [-2.765MB; -2.487MB] or [-9.442%; -8.490%]

scenario:iast_aspects-aspect_iast_do_str

  • 🟩 max_rss_usage [-2.682MB; -2.383MB] or [-9.171%; -8.148%]

scenario:iast_aspects-aspect_iast_do_title

  • 🟩 max_rss_usage [-2.685MB; -2.519MB] or [-9.144%; -8.578%]

scenario:iast_aspects-aspect_iast_do_upper

  • 🟩 max_rss_usage [-2.860MB; -2.508MB] or [-9.768%; -8.565%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants